<template>
  <div class="audit-steps">
    <div v-if="title" class="audit-title">{{ title }}</div>
    <el-scrollbar class="audit-scroll">
      <div class="audit-wrapper">
        <el-steps direction="vertical" v-if="steps" :active="steps.length">
          <el-step v-for="(item, idx) in steps" :key="item.id" :class="{ 'first-step': idx === 0 }">
            <div slot="icon" class="step-icon" :class="{ 'none-operate': !item.operated }"></div>
            <div slot="title" class="step-title" :class="{ 'none-operate': !item.operated }">
              <span>{{ item.title }}</span>
              <template v-if="item.operated">
                <img v-if="item.passed" src="@images/task/audit-pass.png" alt="" />
                <img v-else src="@images/task/audit-reject.png" alt="" />
              </template>
            </div>
            <div slot="description" class="description">
              <p v-for="field in item.fields" :key="field.id">
                <span v-if="field.label" class="label">{{ field.label }}：</span>
                <span v-if="field.value" class="value">{{ field.value }}</span>
              </p>
            </div>
          </el-step>
        </el-steps>
      </div>
    </el-scrollbar>
  </div>
</template>

<script>
export default {
  name: 'AuditSteps',
  components: {},
  props: {
    title: {
      type: String,
      default: '审批流程',
    },
    steps: {
      type: Array,
    },
  },
  data() {
    return {}
  },
  computed: {},
  watch: {},
  created() {},
  mounted() {},
  methods: {},
}
</script>
<style lang="scss" scoped>
.audit-steps {
  height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  .audit-title {
    font-size: 18px;
    font-weight: bold;
    color: #333;
    padding: 20px 20px 10px;
  }
  .audit-wrapper {
    padding: 0 20px 10px 20px;
    ::v-deep .el-steps {
      .el-step__head {
        width: 12px;
        padding-top: 18px;
      }
      .el-step__line {
        left: 5px;
        top: 32px;
        bottom: -27px;
      }
      .el-step__icon {
        border: none;
        background: transparent;
        margin-left: -6px;
        margin-top: 2px;
      }
      .step-icon {
        background: #2e62ab;
        width: 12px;
        height: 12px;
        border-radius: 50%;
        &.none-operate {
          width: 15px;
          height: 15px;
          background: none;
          border: 2px solid #666;
        }
      }
      .step-title {
        display: flex;
        align-items: center;
        margin-top: 20px;
        &.none-operate {
          color: #666;
        }
        img {
          margin-left: 10px;
          width: 20px;
        }
      }
      .el-step__description {
        padding-right: 0;
      }
      .description {
        p {
          line-height: 30px;
          font-size: 14px;
        }
      }
    }
  }
}
</style>
